package factory.normal;

/**
 * @description: 工厂模式，定义一个用于创建对象的接口，让子类决定实例化哪一个类。
 *               工厂方法使一个类的实例化延迟到其子类。
 * @author: Fesine
 * @createTime:2016/8/8 19:47
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/8/8 19:47
 */
public class Main {
    public static void main(String[] args) {
        IGFFactory yunNanGFFactory = new YunNanGFFactory();
        BaseGF yunNanGF = yunNanGFFactory.createGF();
        yunNanGF.eatFood();
        yunNanGF.shopping();
        System.out.println("using factory mode...");
        IAnimalFactory catFactory = new CatFactory();
        Animal cat = catFactory.createAnimal();
        cat.sayHello();
        cat.sound();

        IAnimalFactory dogFactory = new DogFactory();
        Animal dog = dogFactory.createAnimal();
        dog.sayHello();
        dog.sound();

        IAnimalFactory duckFactory = new DuckFactory();
        Animal duck = duckFactory.createAnimal();
        duck.sayHello();
        duck.sound();
    }
}
